package com.zhitxx.progress_webview

import android.os.Handler
import android.os.Message
import android.util.Log
import android.webkit.WebChromeClient
import android.webkit.WebView

/**
 * 获取进度参数
 */
class ProgressWebClient(progress: Handler) : WebChromeClient() {
    private val TAG: String = javaClass.simpleName
    var progressHandler: Handler = progress

    override fun onProgressChanged(view: WebView?, newProgress: Int) {
        val message: Message = Message()
        if (newProgress == 100) {
            message.obj = newProgress
            progressHandler.sendMessageDelayed(message, 200)
        } else {
            if (newProgress < 10) {
                newProgress == 10
            }
            message.obj = newProgress
            progressHandler.sendMessage(message)
        }
        super.onProgressChanged(view, newProgress)
    }


}